# -*- coding: utf-8 -*-
"""
@date: 2021/8/25 19:50
@file: l2_normalize_use.py
@author: lilong
@desc: 
"""

"""
参考：https://blog.csdn.net/abiggg/article/details/79368982
"""

import tensorflow as tf

input_data = tf.constant([[1.0, 2, 3],
                          [4.0, 5, 6],
                          [7.0, 8, 9]])

output = tf.nn.l2_normalize(input_data, dim=0)
with tf.Session() as sess:
    print(sess.run(input_data))
    print(sess.run(output))

"""输出

dim = 0, 为按列进行l2范化

[[1. 2. 3.]
[4. 5. 6.]
[7. 8. 9.]]
[[0.12309149 0.20739034 0.26726127]
[0.49236596 0.51847583 0.53452253]
[0.86164045 0.82956135 0.80178374]]

"""
